var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("Loader"),
    s = e("AssetsManager"),
    l = e("AudioManager"),
    c = e("CommonHelper"),
    d = e("sdkConfig"),
    h = e("Toast"),
    _ = e("AnalyticsManager"),
    u = cc._decorator,
    p = u.ccclass,
    m = u.property,
    f = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.coinNode = null),
                (t.zs_Node = null),
                (t.coinFab = null),
                (t.role_ske_list = [
                    "C7/C7",
                    "C9/C9",
                    "C12/C12",
                    "C17/C17",
                    "C21/C21",
                    "C36/C36",
                    "C37/C37",
                    "C41/C41",
                    "C45/C45",
                    "C47/C47",
                    "C71/C71",
                    "C90/C90",
                    "C96/C96",
                    "C16/C16",
                    "C67/C67",
                    "C86/C86"
                ]),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.onLoad = function () {
                cc.game.addPersistRootNode(this.node);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_COCOS_ANALYTICS, this.sendCocosAnalytcs, this);
            }),
            (t.prototype.detachEvents = function () {}),
            (t.prototype.sendCocosAnalytcs = function (e, t) {
                d.default.platform != d.EPlatform.No_AD &&
                    d.default.platform != d.EPlatform.test &&
                    _.default.getInstance().raiseCustomEvent(_.EAnalyticsEvent.Success, {name: t.name, info: t.info});
            }),
            (t.prototype.showPopup = function (e, t) {
                var o = s.default.getInstance().getPrefabNode(e);
                cc.find("Canvas").getChildByName(e) && cc.find("Canvas").getChildByName(e).destroy();
                var n = cc.instantiate(o);
                cc.find("Canvas").addChild(n), t && t(n);
            }),
            (t.prototype.showCoinAndZs = function (e) {
                this.coinNode.active = this.zs_Node.active = e;
            }),
            (t.prototype.addCoinAni = function (e, t) {
                var o = this,
                    n = null;
                0 == t
                    ? (h.default.showNewToast("获得" + e + "个金币"),
                      (n = this.coinNode),
                      l.default.getInstance().playFx("get_coin"))
                    : 1 == t && (h.default.showNewToast("获得" + e + "个钻石"), (n = this.zs_Node));
                for (
                    var r = function (e) {
                            var o = cc.instantiate(s.coinFab);
                            (o.active = !0), (o.children[0].active = 0 == t), (o.children[1].active = 1 == t);
                            var a = c.default.getRandomInt(-600, 600),
                                i = c.default.getRandomInt(-600, 600);
                            if (!o) return "continue";
                            o.setPosition(cc.v2(a, i));
                            var r = s.node.convertToWorldSpaceAR(n.getPosition()),
                                l = cc.find("Canvas").convertToNodeSpaceAR(r),
                                d = [
                                    cc.v2(-50 + c.default.getRandomInt(-50, 50), 100 + c.default.getRandomInt(-50, 50)),
                                    cc.v2(
                                        -100 + c.default.getRandomInt(-50, 50),
                                        300 + c.default.getRandomInt(-50, 50)
                                    ),
                                    cc.v2(l.x, l.y)
                                ],
                                h = cc.bezierTo(1, d),
                                _ = cc.callFunc(function () {
                                    o.destroy();
                                });
                            s.scheduleOnce(function () {
                                cc.find("Canvas").addChild(o), o.runAction(cc.sequence(h, _));
                            }, 0.008 * e);
                        },
                        s = this,
                        d = 0;
                    d < 10;
                    d++
                )
                    r(d);
                this.scheduleOnce(function () {
                    var n = i.GlobalParams.PlayerInfo.value;
                    0 == t ? (n.coin += e) : 1 == t && (n.zs += e),
                        (i.GlobalParams.PlayerInfo.value = n),
                        o.emitEvent(0 == t ? a.default.UPDATE_HAVE_COIN_NUMBER : a.default.UPDATE_HAVE_ZS_NUMBER);
                }, 1);
            }),
            (t.prototype.getRoleSkele = function (e, t) {
                r.default.loadBundleRes(
                    "Role",
                    this.role_ske_list[e],
                    function (e) {
                        t(e);
                    },
                    sp.SkeletonData
                );
            }),
            (t.prototype.consumeCoinAndZs = function (e, t) {
                var o = i.GlobalParams.PlayerInfo.value;
                0 == e
                    ? ((o.coin -= t), this.playerTaskOverInfo(5, t))
                    : 1 == e && ((o.zs -= t), this.playerTaskOverInfo(6, t)),
                    (i.GlobalParams.PlayerInfo.value = o),
                    this.emitEvent(0 == e ? a.default.UPDATE_HAVE_COIN_NUMBER : a.default.UPDATE_HAVE_ZS_NUMBER);
            }),
            (t.prototype.playerTaskOverInfo = function (e, t) {
                var o = i.GlobalParams.PlayerTaskInfo.value;
                -1 != o.schedule[e] &&
                    ((o.schedule[e] += t),
                    (i.GlobalParams.PlayerTaskInfo.value = o),
                    this.emitEvent(a.default.SEND_UPDATE_TASK_INFO));
            }),
            __decorate([m(cc.Node)], t.prototype, "coinNode", void 0),
            __decorate([m(cc.Node)], t.prototype, "zs_Node", void 0),
            __decorate([m(cc.Node)], t.prototype, "coinFab", void 0),
            __decorate([p], t)
        );
    })(n.default);
o.default = f;
